Title: SQL BT (By-BKK) / 20 Union
Tags: Obsidian_to_Anki

Q: What does the UNION operator accomplish in SQL?
A: Combines two queries and removes duplicates

Q: How does the SQL EXCEPT operator function?
A: EXCEPT returns only rows in the first set, not in the second

Q: Which set operation extensions keep duplicate rows?
A: INTERSECT ALL and EXCEPT ALL

Q: Why does the order of queries matter when using EXCEPT?
A: Order sensitivity applies to EXCEPT, like left and right joins

Q: How do you keep all rows when combining queries in SQL?
A: UNION ALL includes all matched rows, even duplicates

Q: What does the SQL UNION operator do?
A: Combines the results of two queries and removes duplicate rows

Q: When would you use UNION ALL instead of UNION?
A: When you want to include duplicate rows from both queries

Q: What must match for two queries joined by UNION?
A: Column count, order, and data type

Q: True/False: UNION removes duplicates, UNION ALL keeps all rows
A: True

Q: Where are UNION operations applied in the SQL execution order?
A: Before ORDER BY and LIMIT

Q: What does INTERSECT return in SQL?
A: Rows that are identical in both result sets

Q: How does the EXCEPT operator work in SQL?
A: Returns rows in the first result set that aren't in the second

Q: True/False: EXCEPT is order-sensitive
A: True

Q: True/False: INTERSECT and EXCEPT discard duplicate rows
A: True

Q: What operators allow duplicates to be retained with set operations?
A: INTERSECT ALL and EXCEPT ALL (if supported by the database)